﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary.DAO;
using ClassLibrary.Entity;
using mprsc.Reports;

namespace mprsc
{
    public partial class NewBooking : Form
    {
        TblCustomersDAO customerDAO = new TblCustomersDAO(Global.CONNECTION_STRING);
        TblJobsDAO JobsDAO = new TblJobsDAO(Global.CONNECTION_STRING);
        TblModelDAO modelDAO = new TblModelDAO(Global.CONNECTION_STRING);
        TblPhonesDAO PhonesDAO = new TblPhonesDAO(Global.CONNECTION_STRING);
        TblQuoteDAO QuoteDAO = new TblQuoteDAO(Global.CONNECTION_STRING);
        TblStatusJobDAO StatusJobDAO = new TblStatusJobDAO(Global.CONNECTION_STRING);
        TblLoanPhoneDAO LoanPhoneDAO = new TblLoanPhoneDAO(Global.CONNECTION_STRING);
        TblQuoteDAO quoteDAO = new TblQuoteDAO(Global.CONNECTION_STRING);
        TblProductsDAO productsDao = new TblProductsDAO(Global.CONNECTION_STRING);
        TblPartUsedDAO partUsedDAO = new TblPartUsedDAO(Global.CONNECTION_STRING);
        TblJobNoteDAO jobnoteDAO = new TblJobNoteDAO(Global.CONNECTION_STRING);

        public delegate void SendMessage(string Message);
        public SendMessage Sender;
        public SendMessage Sender1; 
        public NewBooking()
        {
            InitializeComponent();
            //Tao con tro toi hàm GetMessage
            Sender = new SendMessage(GetMessage);
            Sender1 = new SendMessage(GetMessage1);
            LoadCustomer();
            Load_Type();
            load_manager();
            LoadBrand();
            LoadCondition();
            LoadPhoneNetWork();
            LoadPartDescription();
            if (cb_jobtype.SelectedValue.ToString() == "1")
            {
                p_wanranty.Enabled = false;
            }
          
        }
        //Hàm có nhiem vu lay tham so truyen vào
        private void GetMessage(string Message)
        {
            txt_ID.Text = Message;
        }

        //Hàm có nhiem vu lay tham so truyen vào
        private void GetMessage1(string Message)
        {
            txt_jobID.Text = Message;
        }
        private void AddNewCustomer_Load(object sender, EventArgs e)
        {
            this.CenterToParent();
            string idJob = txt_jobID.Text;
            string idC = txt_ID.Text;

            DataTable dt = JobsDAO.GetCustomerIndex(Global.ConvertToInt(idJob));
            foreach (DataRow dr in dt.Rows)
            {
                idC = dr["CustomerIndex"].ToString();
            }
            if (idJob != "")
            {
                LoadJobbyID(Convert.ToInt32(idJob));
                cb_Customer.Enabled = false;
                LoadCustomer_ByID(Global.ConvertToInt(idC));
                LoadLoanPhoneByJobID();
                loadQuote();
                LoadStatusJob();
                loadpartUsed();
                button10.Enabled = true;
                btnMarkJobBER.Enabled = true;
                LoadJobNote();
              
            }
            else
            {
                button10.Enabled = false;
                btnMarkJobBER.Enabled = false;    
                txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
                LoadCustomer_ByID(Global.ConvertToInt(idC));

                btnLoanPhone.Enabled = false;
                btnquote.Enabled = false;
                btnUpdateStatus.Enabled = false;
            }

            
        }
        
        // Load List Customer
        private void LoadCustomer()
        {
            cb_Customer.DataSource = customerDAO.GetStaffList(0);
            cb_Customer.DisplayMember = "CustomerFullname";
            cb_Customer.ValueMember = "CustomerIndex";
        } 
        
        // Load Type - Nonwarranty - Warranty
        private void Load_Type()
        {
            var Type = new Dictionary<int, string>();
            Type.Add(1, "Non-Warranty");
            Type.Add(2, "Warranty");
            cb_jobtype.DataSource = new BindingSource(Type, null);
            cb_jobtype.DisplayMember = "Value";
            cb_jobtype.ValueMember = "Key";
        }
        // load manage
        private void load_manager()
        {
            cb_bookedBy.DataSource = customerDAO.GetStaffList(1);
            cb_bookedBy.DisplayMember = "CustomerFullname";
            cb_bookedBy.ValueMember = "CustomerIndex";
        }

        //load Brand
        private void LoadBrand()
        {
            cb_Brand.DataSource = JobsDAO.LoadBrandPhone();
            cb_Brand.DisplayMember = "BrandName";
            cb_Brand.ValueMember = "IDBrand";
        }

        // Load Phone Condition
        private void LoadCondition()
        {
            var Condition = new Dictionary<int, string>();
            Condition.Add(1, "Poor");
            Condition.Add(2, "Fair");
            Condition.Add(3, "Good");
            cb_PhoneCondition.DataSource = new BindingSource(Condition, null);
            cb_PhoneCondition.DisplayMember = "Value";
            cb_PhoneCondition.ValueMember = "Key";
        }
        // Load Phone NetWork
        private void LoadPhoneNetWork()
        {
            var network = new Dictionary<int, string>();
            network.Add(1, "Optus");
            network.Add(2, "Telstra");
            network.Add(3, "Vodafone");
            network.Add(4, "Virgin");
            cb_PhoneNetwork.DataSource = new BindingSource(network, null);
            cb_PhoneNetwork.DisplayMember = "Value";
            cb_PhoneNetwork.ValueMember = "Key";
        }

        private void cb_Customer_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadCustomer_ByID(Global.ConvertToInt(cb_Customer.SelectedValue.ToString()));
        }

        private void LoadCustomer_ByID(int CusID)
        {
            if (CusID != 0)
            {
                TblCustomers cus = customerDAO.CustomerById(CusID);
                if (cus != null)
                {
                  //  LoadCustomer();
                    cb_Customer.Text = cus.CustomerFullname;
                    linkName.Text = cus.CustomerFullname;
                    txt_ID.Text = cus.CustomerIndex.ToString();  
                }
                else
                {
                }
            }
            else
            {
                string idJob = txt_jobID.Text;
                DataTable dtCus = JobsDAO.GetJob(Global.ConvertToInt(idJob), "");
                //LoadCustomer();
                foreach (DataRow r in dtCus.Rows)
                {
                    cb_Customer.Text = r["CustomerFullname"].ToString();
                    txt_ID.Text = r["CustomerIndex"].ToString();                  
                }
            }    
        }

        private void linkName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //Tạo AddNewCustomer
            NewCustomer addnewCus = new NewCustomer();
            addnewCus.Sender(txt_ID.Text.Trim()); //Gọi delegate
            //this.Hide();
            addnewCus.Show();       
        }

        private void cb_jobtype_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_jobtype.SelectedValue.ToString() == "1")
            {
                p_wanranty.Enabled = false;         
            }
            else
            {
                p_wanranty.Enabled = true;            
            }
        }

        private void cb_Brand_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cb_Brand.Text == "System.Data.DataRowView" || cb_Brand.Text =="")
            {
                cb_PhoneModel.DataSource = modelDAO.GetModel();
                cb_PhoneModel.DisplayMember = "Model";
                cb_PhoneModel.ValueMember = "Model";
            }
            else
            {
                DataTable dt = modelDAO.GetModelByIdBrand(Global.ConvertToInt(cb_Brand.SelectedValue.ToString()));
                foreach (DataRow dr in dt.Rows)
                {
                    cb_PhoneModel.DataSource = dt;
                    cb_PhoneModel.DisplayMember = "Model";
                    cb_PhoneModel.ValueMember = "Model";
                }
            }
        }

        private void txt_PhoneIMEI_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void ck_battery_CheckedChanged(object sender, EventArgs e)
        {
            if (ck_battery.Checked)
            {
                txt_Accessories.Text += ck_battery.Text.Trim() + ",";
            }
        }

        private void ck_BatteryCover_CheckedChanged(object sender, EventArgs e)
        {
            if (ck_BatteryCover.Checked)
            {
                txt_Accessories.Text += ck_BatteryCover.Text.Trim() + ",";
            }
        }

        private void ck_ACCharger_CheckedChanged(object sender, EventArgs e)
        {
            if (ck_ACCharger.Checked)
            {
                txt_Accessories.Text += ck_ACCharger.Text.Trim() + ",";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            txt_Descriptions.Text += listFault.SelectedItem.ToString() + "; ";
        }

        private void button3_Click(object sender, EventArgs e)
        {
                bool flag = false;
                if (txt_PhoneIMEI.Text.Trim().Length == 15)
                {
                    try
                    {
                        #region Insert Phones

                        TblPhones phone = new TblPhones();
                        phone.IMEINo = txt_PhoneIMEI.Text.Trim();
                        phone.Model = cb_PhoneModel.Text;
                        phone.Manufacturer = cb_Brand.Text;
                        phone.PhoneBrand = cb_Brand.SelectedValue.ToString();
                        phone.PhoneMSN = txt_SerialNo.Text.Trim();
                        phone.PhoneCondition = cb_PhoneCondition.Text.Trim();
                        phone.PhoneConditionDetails = txt_ConditionDetails.Text.Trim();
                        phone.PhoneNetworkWith = cb_PhoneNetwork.Text.Trim();
                        phone.LockPhone = txt_LockCode.Text;

                        DataTable dt = null;

                        if (txt_jobID.Text == "")
                        {
                            phone.PhoneID = 0;
                            dt = PhonesDAO.InsUpdPhone(phone, 1);
                            foreach (DataRow dr in dt.Rows)
                                phone.PhoneID = Convert.ToInt32(dr["PhoneID"].ToString());
                        }
                        else
                        {
                            int JobNo = Convert.ToInt32(txt_jobID.Text);
                            DataTable dt2 = JobsDAO.GetJob(JobNo, "");
                            foreach (DataRow dr2 in dt2.Rows)
                            {
                                phone.PhoneID = Convert.ToInt32(dr2["PhoneID"].ToString());
                            }
                            PhonesDAO.InsUpdPhone(phone, 2);
                        }
                        #endregion

                        #region Jobs
                        TblJobs Job = new TblJobs();
                        Job.CustomerIndex = Convert.ToInt32(txt_ID.Text);
                        Job.DateBook = DateTime.Now;
                        Job.JobType = Convert.ToInt32(cb_jobtype.SelectedValue.ToString());

                        Job.FaultDescription = txt_Descriptions.Text;
                        Job.OrtheInstructions = txt_OtherInstructions.Text;
                        Job.AccessoriesWithPhone = txt_Accessories.Text;
                        Job.BookByID = Convert.ToInt32(cb_bookedBy.SelectedValue.ToString());
                        Job.BookByName = cb_bookedBy.Text;
                        Job.PhoneID = phone.PhoneID;
                        Job.CurrentStatus = 0;
                        Job.ExpectedCompletionDate = DateTime.Now;
                        Job.DateComplete = DateTime.Now;
                        Job.RepairCharge = 0;
                        Job.LPCharge = 0;
                        Job.OrtherCharge = 0;
                        Job.SalesAmount = Convert.ToDecimal(Convert.ToDecimal(Job.RepairCharge) + Convert.ToDecimal(Job.LPCharge) + Convert.ToDecimal(Job.OrtherCharge));
                        Job.PaymentMethod = "";

                        Job.QuotationStatus = 1;
                        Job.ApprovalStatus = 1;

                        DataTable dtJobs = null;
                        if (txt_jobID.Text == "")
                        {
                            Job.JobID = 0;

                            dtJobs = JobsDAO.InsertUpdJob(Job, 1);
                            foreach (DataRow drJob in dtJobs.Rows)
                            {
                                txt_jobID.Text = drJob["JobID"].ToString();
                            }
                            TblQuote quote = new TblQuote();
                            quote.JobID = Convert.ToInt32(txt_jobID.Text);
                            quote.InspectionFee = 0;
                            quote.AmountQuoted = 0;
                            quote.DateQuoted = DateTime.Now;
                            quote.QuoteStatus = "Book - in";
                            quote.OutCome = "";
                            quote.Notes = "";
                            quote.Itemised = "";

                            QuoteDAO.InsTblQuote(quote, 1);


                        }
                        else
                        {
                            int Jobid = Convert.ToInt32(txt_jobID.Text);
                            Job.JobID = Jobid;
                            dtJobs = JobsDAO.GetJob(Jobid, "");

                            JobsDAO.InsertUpdJob(Job, 2);
                        }

                        #endregion

                        #region StatusJob

                        TblJobStatus JobStatus = new TblJobStatus();
                        JobStatus.JobID = Convert.ToInt32(txt_jobID.Text);
                        JobStatus.StatusDate = Convert.ToDateTime(DateTime.Now);
                        JobStatus.StatusJobs = "Book - In";
                        JobStatus.Notes = JobStatus.StatusJobs;
                        StatusJobDAO.JobStatusIns(JobStatus);

                        #endregion

                        flag = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    if (flag)
                    {
                        MessageBox.Show("Add new booking sucessful!");
                        LoadCustomer_ByID(Global.ConvertToInt(txt_ID.Text));
                        LoadJobbyID(Global.ConvertToInt(txt_jobID.Text));
                    }
                }
                else
                {
                    MessageBox.Show("Phone IMEI No have 15 character");
                }
        }

        private void LoadJobbyID(int JobNo)
        {
            DataTable dt_JobById = JobsDAO.GetJob(JobNo, "");

            foreach (DataRow r in dt_JobById.Rows)
            {
                txt_jobID.Text = r["JobID"].ToString();
                txtDate.Text = Convert.ToDateTime(r["DateBook"].ToString()).ToString("dd/MM/yyyy");
                linkName.Text = r["CustomerFullname"].ToString();
                txt_quoted.Text = r["AmountQuoted"].ToString();
                string CusID = r["CustomerIndex"].ToString();

                DataTable dt = StatusJobDAO.GetCurrentStatusJob(JobNo);
                foreach (DataRow dr in dt.Rows)
                {
                    txt_CurentStatus.Text = dr["StatusJobs"].ToString();
                    txt_StatusDate.Text = Convert.ToDateTime(dr["StatusDate"]).ToString("dd/MM/yyyy");
                }
               
                if (cb_jobtype.SelectedValue.ToString() == "2")
                {
                    p_wanranty.Enabled = true;
                }
                else if (cb_jobtype.SelectedValue.ToString() == "0" || cb_jobtype.SelectedValue.ToString() == "1")
                {
                    p_wanranty.Enabled = false;
                }

                txt_Descriptions.Text = r["FaultDescription"].ToString();
                txt_OtherInstructions.Text = r["OrtheInstructions"].ToString();
                txt_Accessories.Text = r["AccessoriesWithPhone"].ToString();
                cb_PhoneModel.Text = r["Model"].ToString();
                LoadPhoneByid(Convert.ToInt32(r["PhoneID"]));
            }
        }

        private void LoadPhoneByid(int Phoneid)
        {
            DataTable dt_PhoneByid = PhonesDAO.GetPhoneById(Phoneid);
            foreach (DataRow r in dt_PhoneByid.Rows)
            {
                txt_PhoneIMEI.Text = r["IMEINo"].ToString();
                //txtModel.Text = r["Model"].ToString();
                cb_PhoneModel.Text = r["Model"].ToString();
                txt_SerialNo.Text = r["PhoneMSN"].ToString();
                cb_Brand.SelectedValue = r["PhoneBrand"].ToString();
                cb_PhoneCondition.Text = r["PhoneCondition"].ToString();
                txt_ConditionDetails.Text = r["PhoneConditionDetails"].ToString();
                cb_PhoneNetwork.Text = r["PhoneNetworkWith"].ToString();
                txt_LockCode.Text = r["LockPhone"].ToString();
            }
        }

        // Load LoanPhone DEtail
        private void LoadLoanPhoneByJobID()
        {
            string id = txt_jobID.Text;
            DataTable LPhoneByJob = LoanPhoneDAO.LoadLoanPhoneByJobID(Convert.ToInt32(id));
            foreach (DataRow dr in LPhoneByJob.Rows)
            {
                txt_LoanID.Text = dr["LoanID"].ToString();
                txt_LPhoneID.Text = dr["LPhoneID"].ToString();
                txt_Brand.Text = dr["Brand"].ToString();
                txt_Model.Text = dr["Model"].ToString();
                txt_IMEI.Text = dr["IMENo"].ToString();
                txtInculded.Text = dr["AccessoriesIncluded"].ToString();
                txt_Amount.Text = dr["AmountDeposited"].ToString();
                txt_LoanFree.Text = dr["LoanFee"].ToString();
                txt_Notes.Text = dr["Notes"].ToString();
                txt_DateIn.Text = Convert.ToDateTime(dr["DateIn"].ToString()).ToString("dd/MM/yyy");
                txt_DateOut.Text = Convert.ToDateTime(dr["DateOut"].ToString()).ToString("dd/MM/yyyy");
                txt_Payment.Text = dr["PaymentMethod"].ToString();
                if (Convert.ToBoolean(dr["DepositeTaken"]) == true)
                    ck_Deposit.Checked = true;
                else
                    ck_DepositRefuned.Checked = true;
            }
        }

        //Load Quote
        private void loadQuote()
        {
            string id = txt_jobID.Text;
            try
            {
                if (id != null)
                {
                    DataTable dtQuote = quoteDAO.GetQuote(Convert.ToInt32(id));
                    grdQuote.DataSource = dtQuote;       
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        // Load StatusJob
        public void LoadStatusJob()
        {
            string id = txt_jobID.Text;
            if (id != null)
            {
                grdJobStatus.DataSource = StatusJobDAO.GetJobStatus(Convert.ToInt32(id));
            }
        }


        //Load Part
        private void LoadPartDescription()
        {
            cb_PartDes.DataSource = productsDao.GetProductsList(1);
            cb_PartDes.ValueMember = "ProductID";
            cb_PartDes.DisplayMember = "ProductName";
        }
        private void txt_Search_TextChanged(object sender, EventArgs e)
        {
            cb_PartDes.DataSource = productsDao.GetPartSearch(txt_Search.Text.Trim(), 1);
            cb_PartDes.ValueMember = "ProductID";
            cb_PartDes.DisplayMember = "ProductName";
          
        }

        private void cb_PartDes_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dt = productsDao.GetPart_ByID(Global.ConvertToInt(cb_PartDes.SelectedValue.ToString()));
            foreach (DataRow dr in dt.Rows)
            {
                txtCost.Text = dr["Cost"].ToString();
                txtRRP.Text = dr["RRP"].ToString();
                txtModel.Text = dr["Model"].ToString();
                txtBrand.Text = dr["BrandName"].ToString();
                txtProductCode.Text = dr["productCode"].ToString();
            }
         
        }

        private void button5_Click(object sender, EventArgs e)
        {
            bool flag = false;
            if (txt_Quantity.Text == "" || txtCost.Text == "" )
            {
                this.validationProvider1.ValidationMessages(!this.validationProvider1.Validate());
            }
            else
            {     
                try
                {
                    TblPartUsed partUsed = new TblPartUsed();

                    int id = Global.ConvertToInt(txt_jobID.Text);

                    if (id != 0)
                    {
                        partUsed.ProductID = Global.ConvertToInt(cb_PartDes.SelectedValue.ToString());
                        partUsed.PhoneBrand = txtBrand.Text.Trim();
                        partUsed.PhoneModel = txtModel.Text.Trim();
                        partUsed.PartDescription = cb_PartDes.Text + " .Product code : " + txtProductCode.Text.Trim();
                        partUsed.Quantity = Global.ConvertToInt(txt_Quantity.Text.Trim());
                        partUsed.DateEntered = DateTime.Now;
                        partUsed.JobID = id;

                        partUsedDAO.InsUpPartUsed(partUsed, 1);

                        flag = true;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (flag)

                loadpartUsed();
        }

        public void loadpartUsed()
        {
            string id = txt_jobID.Text;

            try
            {
                if (id != null)
                {
                    grdPartsUsed.DataSource = partUsedDAO.GetPartUsed(Convert.ToInt32(id));
                   
                }
                else
                {
                    txt_Quantity.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            bool flag = false;
            //string id = Request.QueryString["id"];
            string id = txt_jobID.Text;
            try
            {
                TblJobStatus JobStatus = new TblJobStatus();
                JobStatus.JobID = Convert.ToInt32(id);
                JobStatus.StatusDate = Convert.ToDateTime(DateTime.Now);
                JobStatus.StatusJobs = "Repair Completed";
                JobStatus.Notes = txtDescripWorkDetail.Text;
                StatusJobDAO.JobStatusIns(JobStatus);

                StatusJobDAO.UpdateQuoteComplete(JobStatus.JobID, JobStatus.StatusJobs);
                flag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (flag)
                LoadJobbyID(Global.ConvertToInt(id));
                LoadCustomer_ByID(Global.ConvertToInt(txt_ID.Text));
        }

        private void button7_Click(object sender, EventArgs e)
        {
            txtDescripWorkDetail.Text += lstFaultDes.Text + ",";
        }

        private void btnMarkJobBER_Click(object sender, EventArgs e)
        {
            string id = txt_jobID.Text;
            bool flag = false;
            try
            {
                TblJobStatus JobStatus = new TblJobStatus();
                JobStatus.JobID = Convert.ToInt32(id);
                JobStatus.StatusDate = Convert.ToDateTime(DateTime.Now);
                JobStatus.StatusJobs = "BER";
                JobStatus.Notes = "BER - Beyond Economical Repair " + txtDescripWorkDetail.Text;
                StatusJobDAO.JobStatusIns(JobStatus);

                StatusJobDAO.UpdateQuoteComplete(JobStatus.JobID, JobStatus.StatusJobs);
                flag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (flag)
            {
                LoadJobbyID(Global.ConvertToInt(id));
                LoadCustomer_ByID(Global.ConvertToInt(txt_ID.Text));
            }
        }

        // load Action List
        private void LoadJobNote()
        {
            string id = txt_jobID.Text;
            grdAction.DataSource = jobnoteDAO.GetJobNotes(Convert.ToInt32(id));  
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (grdAction.RowCount != 1)
            {
                string id = grdAction.CurrentRow.Cells["IDJobNote"].Value.ToString();
                ActionList actionList = new ActionList();
                actionList.Sender(id);
                this.Hide();
                actionList.Show();
            }
            else
            {
                string id = txt_jobID.Text;
                ActionList actionList = new ActionList();
                actionList.Sender(id);
                this.Hide();
                actionList.Show();
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            string id = txt_jobID.Text;
            //Tạo ISSUELOANPHONE
            ISSUELOANPHONE issueLoanPhone = new ISSUELOANPHONE();
            issueLoanPhone.Sender(id); //Gọi delegate
            this.Hide();
            issueLoanPhone.Show();  
        }

        private void btnquote_Click(object sender, EventArgs e)
        {
            string id = txt_jobID.Text;
            EDITQUOTE quote = new EDITQUOTE();
            quote.Sender(id); 
            quote.Show();
        }

        private void btnUpdateStatus_Click(object sender, EventArgs e)
        {
            ActionList actionList = new ActionList();
            actionList.Show();
        }

        private void btnPrintSA_Click(object sender, EventArgs e)
        {
            /*
            ReportTechCopy rp = new ReportTechCopy();       
            string idJob = txt_jobID.Text;
            rp.Sender(idJob);
            rp.Show();
             * */

            var data = JobsDAO.reportJob1(Global.ConvertToInt(txt_jobID.Text));
            var report = new CrystalReport1();
            report.SetDataSource(data);
            var reportViewer = new ReportViewer();
            reportViewer.SetReport(report);
            reportViewer.Show(this);

            var data1 = JobsDAO.reportJob1(Global.ConvertToInt(txt_jobID.Text));
            var report1 = new CrystalReport3();
            report1.SetDataSource(data1);
            var reportViewer1 = new ReportViewer();
            reportViewer1.SetReport(report1);
            reportViewer1.Show(this);


        }

        private void btnPrintInvoice_Click(object sender, EventArgs e)
        {
            var data = JobsDAO.reportJob1(Global.ConvertToInt(txt_jobID.Text));
            var report = new CrystalReport2();
            report.SetDataSource(data);
            var reportViewer = new ReportViewer();
            reportViewer.SetReport(report);
            reportViewer.Show(this);
        }
    }
}
